package com.drinkian.business.room.controller;

import com.drinkian.business.room.entity.po.Room;
import com.drinkian.business.room.entity.vo.VRoomAdd;
import com.drinkian.business.room.service.IRoomService;
import com.drinkian.entity.RequestResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("room")
public class RoomController {

    @Autowired
    private IRoomService iRoomService;

    @RequestMapping("addRoom")
    public RequestResult addRoom(@RequestBody VRoomAdd vRoomAdd) {
        return iRoomService.addRoom(vRoomAdd);
    }

    @GetMapping("getRoomList")
    public RequestResult getRoomList(@RequestParam("current") int current, @RequestParam("size") int size) {
        return iRoomService.getRoomList(current, size);
    }

    @GetMapping("searchRoomListByTitle")
    public RequestResult searchRoomListByTitle(@RequestParam("title") String title) {
        return iRoomService.searchRoomListByTitle(title);
    }

    @GetMapping("getRoomListByUploaderId")
    public RequestResult getRoomListByUploaderId(@RequestParam("current") int current, @RequestParam("size") int size, @RequestParam("uploaderId") Integer uploaderId) {
        return iRoomService.getRoomListByUploaderId(current, size, uploaderId);
    }

    @GetMapping("deleteRoomById")
    public RequestResult deleteRoomById(@RequestParam("id")Integer id){
        return iRoomService.deleteRoomById(id);
    }

    @PostMapping("updateRoom")
    public RequestResult updateRoom(@RequestBody Room room){
        return iRoomService.updateRoom(room);
    }

    @GetMapping("getUncheckRoomList")
    public RequestResult getUncheckRoomList(@RequestParam("current")Integer current, @RequestParam("size")Integer size){
        return iRoomService.getUncheckRoomList(current, size);
    }

    @GetMapping("examUncheckRoom")
    public RequestResult examUncheckRoom (@RequestParam("roomId")Integer roomId, @RequestParam("code")Integer code){
        return iRoomService.examUncheckRoom(roomId, code);
    }
}
